<template>
	<view>
		<view class="webkit" style="background: #175e3c;padding: 24upx;padding-right: 0;">
			<image :src="res.avatar" style="width: 120upx;height: 120upx;margin-right: 24upx;border-radius: 50%;margin-top: 23upx;"></image>
			<view class="flex" style="width: 552upx;">
				<view class="webkit" style="margin-bottom: 8upx;">
					<view class="flex">
						<text style="font-size: 36upx;color: #e2fcfb;font-weight: bold;margin-right: 20upx;" v-cloak> v-cloakres.nickname}}</text>
						<text style="font-size: 24upx;color: #e2fcfb;" v-cloak>{{res.levelname}}</text>
					</view>
					<view style="height: 48upx;background: #e2fcfb;border-top-left-radius: 48upx;border-bottom-left-radius: 48upx;padding: 0 20upx;">
						<image src="../../static/security.png" mode="" style="width: 34upx;height: 34upx;position: relative;top: 6upx;left: -4upx;"></image>
						<text style="font-size: 24upx;color: #175e3c;">账户安全保障中</text>
					</view>
				</view>
				<view style="margin-bottom: 10upx;"><text style="background: #e2fcfb;color: #175e3c;font-size: 24upx;display: block;width: 100upx;text-align: center;border-radius: 50upx;">已绑定</text></view>
				<view style="font-size: 24upx;color: #e2fcfb;" v-cloak>{{res.coinaddress2}}</view>
			</view>
		</view>
		<view style="background: #fff;">
			<view style="font-size: 32upx;text-align: center;height: 80upx;line-height: 80upx;">数字积分</view>
			<view class="clear" style="padding: 16upx 24upx 24upx;">
				<view v-for="(item,index) in res.new_list" :key="index" class="webkit list" @click="jumpDetail" :data-coin="item.title">
					<image :src="item.pic" mode="" style="width: 48upx;height: 48upx;margin-top: 17upx;margin-right: 16upx;"></image>
					<view>
						<text style="height: 40upx;" v-cloak>{{item.coinname}}</text>
						<text style="font-size: 24upx;color: #999;" v-cloak>{{item.price}}</text>
					</view>
				</view>
			</view>
			<view @click="jump" style="height: 84upx;line-height: 84upx;text-align: center;border-top: 1px solid #ebebeb;font-size: 24upx;color: #999;">优选商品去挑货
				></view>
		</view>
		<view style="margin-top: 100upx;">
			<view style="text-align: center;color: #999;">请使用您常用的以太坊APP</view>
			<view style="text-align: center;color: #999;">转入充值（如IMTOKEN）</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				res: [],
				openid: ''
			};
		},
		onLoad: function() {
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		methods: {
			setAjax() {
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=coin.index&app=1',
					method: 'POST',
					data: {
						'openid': this.openid
					},
					header: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					success: res => {
						uni.hideLoading()
						console.log(res)
						if (res.data.my_bind == "") {
							this.setAjax()
						} else {
							this.res = res.data
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			jump() {
				uni.navigateTo({
					url: '../goods/goods'
				});
			},
			jumpDetail(e) {
				uni.navigateTo({
					url: 'detail/detail?coin=' + e.currentTarget.dataset.coin
				});
			}
		}
	}
</script>

<style>.list{float:left;width:50%;padding:16upx 0;padding-left:40upx;box-sizing:border-box;border-right:1px solid #ebebeb;border-top:1px solid #ebebeb;}.list:nth-child(1),.list:nth-child(2){border-top:0;}.list:nth-child(2n){border-right:0;}.list text{display:block;}</style>